package gamePlay;

import java.io.FileInputStream;
import java.io.IOException;

import org.lwjgl.opengl.GL11;
import org.newdawn.slick.Color;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;

public class TurtleAnimation {

	boolean loadTexture = true;
	
	int direction = 3;

	Texture up;
	Texture down;
	Texture right;
	Texture left;
	Texture spin1;
	Texture spin2;
	Texture spin3;

	public void loadTexture() {
		if (loadTexture) {
			try {
				up = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_up.png"));
				down = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_down.png"));
				right = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_right.png"));
				left = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_left.png"));
				spin1 = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_turn_1.png"));
				spin2 = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_turn_2.png"));
				spin3 = TextureLoader.getTexture("PNG", new FileInputStream(
						"./DATA/Turtle/Turtle_turn_3.png"));
			} catch (IOException e) {
				e.printStackTrace();
			}
			loadTexture = false;
		}
	}

	public void drawTurtle(int[] tPos) {

		Color.white.bind();
		
		switch (direction){
		
		case 0:
			up.bind();
			break;
		case 1:
			left.bind();
			break;
		case 2:
			down.bind();
			break;
		case 3:
			right.bind();
			break;
		}

		GL11.glBegin(GL11.GL_QUADS);
		GL11.glTexCoord2f(0, 0);
		GL11.glVertex2f((tPos[0] + 1) * 32 - 31, (tPos[1] + 1) * 32 - 31);
		GL11.glTexCoord2f(1, 0);
		GL11.glVertex2f((tPos[0] + 1) * 32, (tPos[1] + 1) * 32 - 31);
		GL11.glTexCoord2f(1, 1);
		GL11.glVertex2f((tPos[0] + 1) * 32, (tPos[1] + 1) * 32);
		GL11.glTexCoord2f(0, 1);
		GL11.glVertex2f((tPos[0] + 1) * 32 - 31, (tPos[1] + 1) * 32);
		GL11.glEnd();
	}
	
	public void spinAnimation() {
		
	}
}
